<?php

/**
 * Trader form base class.
 *
 * @method Trader getObject() Returns the current form's model object
 *
 * @package    truetrader
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseTraderForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                    => new sfWidgetFormInputHidden(),
      'user_id'               => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser'), 'add_empty' => false)),
      'character_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TraderCharacter'), 'add_empty' => true)),
      'follower_access_id'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('FollowerAccess'), 'add_empty' => false)),
      'sex_id'                => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Sex'), 'add_empty' => true)),
      'username'              => new sfWidgetFormInputText(),
      'birthday'              => new sfWidgetFormDate(),
      'country'               => new sfWidgetFormInputText(),
      'city_code'             => new sfWidgetFormInputText(),
      'picture'               => new sfWidgetFormInputText(),
      'phone'                 => new sfWidgetFormInputText(),
      'mobile_phone'          => new sfWidgetFormInputText(),
      'skype_address'         => new sfWidgetFormInputText(),
      'personnal_description' => new sfWidgetFormTextarea(),
      'job'                   => new sfWidgetFormInputText(),
      'asset'                 => new sfWidgetFormInputText(),
      'started'               => new sfWidgetFormDate(),
      'weekly_hour'           => new sfWidgetFormInputText(),
      'credit'                => new sfWidgetFormInputText(),
      'follow_credit'         => new sfWidgetFormInputText(),
      'follower_count'        => new sfWidgetFormInputText(),
      'followed_count'        => new sfWidgetFormInputText(),
      'leaver_count'          => new sfWidgetFormInputText(),
      'created_at'            => new sfWidgetFormDateTime(),
      'updated_at'            => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                    => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'user_id'               => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser'))),
      'character_id'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('TraderCharacter'), 'required' => false)),
      'follower_access_id'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('FollowerAccess'), 'required' => false)),
      'sex_id'                => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Sex'), 'required' => false)),
      'username'              => new sfValidatorString(array('max_length' => 128, 'required' => false)),
      'birthday'              => new sfValidatorDate(array('required' => false)),
      'country'               => new sfValidatorString(array('max_length' => 2, 'required' => false)),
      'city_code'             => new sfValidatorInteger(array('required' => false)),
      'picture'               => new sfValidatorString(array('max_length' => 200, 'required' => false)),
      'phone'                 => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'mobile_phone'          => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'skype_address'         => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'personnal_description' => new sfValidatorString(array('max_length' => 300, 'required' => false)),
      'job'                   => new sfValidatorString(array('max_length' => 200, 'required' => false)),
      'asset'                 => new sfValidatorInteger(array('required' => false)),
      'started'               => new sfValidatorDate(array('required' => false)),
      'weekly_hour'           => new sfValidatorInteger(array('required' => false)),
      'credit'                => new sfValidatorInteger(array('required' => false)),
      'follow_credit'         => new sfValidatorInteger(array('required' => false)),
      'follower_count'        => new sfValidatorInteger(array('required' => false)),
      'followed_count'        => new sfValidatorInteger(array('required' => false)),
      'leaver_count'          => new sfValidatorInteger(array('required' => false)),
      'created_at'            => new sfValidatorDateTime(),
      'updated_at'            => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Trader', 'column' => array('user_id')))
    );

    $this->widgetSchema->setNameFormat('trader[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Trader';
  }

}
